bratkartoffel :
Another, in my opinion cleaner approach:\n\nCreate a new file in /etc/sudoers.d/ with content:\n\n%users ALL=NOPASSWD: /sbin/shutdown\n%users ALL=NOPASSWD: /sbin/reboot\n\n\nThis causes sudo to not ask for the password, if any user of group \"users\" tries to execute a shutdown or reboot. Of course you can also specify another group, maybe a newly created group for finer control of reboot permissions.\n\nMore information about the other possible settings for sudo can be found in the Manpage.",
2015-06-16T10:03:36
Wald :
Yes, use the -S switch which reads the password from STDIN:\n$echo <password> | sudo -S <command>\n\nSo to shut down the machine, your command would be like this (just replace <password> with your password):\n$echo <password> | sudo -S poweroff\n\nExposing your password is generally bad idea search for something that can protect / hide it. In the past I've used Jenkins plugins to do this while executing the scripts regularly.",
2015-06-16T09:08:26